# Maintainer: Dekedro <dekedro@tankers.xyz>
pkgname=openjfx
pkgver=17.0.7_p0 # latest LTS
pkgrel=0
pkgdesc="Client application platform for desktop, mobile and embedded systems built on Java"
url="https://openjfx.io/"
# aarch64: java broken
arch="x86_64"
license="GPL-2.0-only WITH Classpath-exception-2.0 AND BSD-3-Clause"
options="net"
makedepends="apache-ant gradle glib-dev gtk+2.0-dev gtk+3.0-dev"
subpackages="$pkgname-doc $pkgname-demos::noarch"
source="$pkgname-$pkgver.tar.gz::https://github.com/openjdk/jfx17u/archive/refs/tags/${pkgver%_p*}+${pkgver##*_p}.tar.gz
	openjfx.profile
	remove-version-suffix-check.patch"
builddir="$srcdir/jfx17u-${pkgver%_p*}-${pkgver##*_p}"

build() {
	gradle -PRELEASE_SUFFIX="-alpine-r$pkgrel" -PCONF=Release sdk apps
}

check() {
	gradle test -x :web:test
}

package() {
	install -dm755 \
		"$pkgdir"/usr/lib \
		"$pkgdir"/usr/share/doc \
		"$pkgdir"/usr/share/licenses \
		"$pkgdir"/usr/share/"$pkgname"/demo

	cp -a build/sdk/lib "$pkgdir"/usr/lib/"$pkgname"
	cp -a build/sdk/legal "$pkgdir"/usr/share/licenses/"$pkgname"
	for app in apps/*/*; do
		test -d "$app"/dist || continue
		cp -a "$app"/dist "$pkgdir"/usr/share/"$pkgname"/demo/"${app##*/}"
	done

	install -Dm644 "$srcdir"/openjfx.profile "$pkgdir"/etc/profile.d/openjfx.sh
}

demos() {
	pkgdesc="$pkgdesc (demos)"

	amove /usr/share/"$pkgname"/demo
}

sha512sums="
95152bf679cf22d4d8cd0216618af329bf4dcee7392f787736f935f3527f7eeeffbf853c0c6e98b863a0f3cdfd8cc61ab9eb478e1c43f676c33b692ba9b3e874  openjfx-17.0.7_p0.tar.gz
41cf37116f748269e74a3333b718a854962088b83c6c56cc2860a21c0d0e24673184cea60502afc5d4cb222de368535c417d93ebe841a75c91c6a88dbb0a5041  openjfx.profile
334dfe8fa4b1a15f9e17b82e5df202f0dcbf8e188970c53058f25d828259a118d8da21676b52406d15567023d49de18c5e06479ca7d0d273ced1b79c6d3f03e7  remove-version-suffix-check.patch
"
